package pers.xiaojun.boot.excel.handler;

import cn.idev.excel.write.metadata.style.WriteCellStyle;
import cn.idev.excel.write.metadata.style.WriteFont;
import cn.idev.excel.write.style.HorizontalCellStyleStrategy;
import org.apache.poi.ss.usermodel.HorizontalAlignment;
import org.apache.poi.ss.usermodel.IndexedColors;
import org.apache.poi.ss.usermodel.VerticalAlignment;

/**
 * 默认表格样式
 *
 * @author xiaojun
 * @since 2025-11-07
 */
public class DefaultCellStyleStrategy extends HorizontalCellStyleStrategy {

    public DefaultCellStyleStrategy() {
        super(getHeadStyle(), contentStyle());
    }

    private static WriteCellStyle getHeadStyle() {
        WriteCellStyle headStyle = new WriteCellStyle();
        WriteFont headFont = new WriteFont();
        headFont.setFontHeightInPoints((short) 14);
        headFont.setBold(true);
        headStyle.setWriteFont(headFont);
        headStyle.setFillForegroundColor(IndexedColors.GREY_25_PERCENT.getIndex());
        headStyle.setHorizontalAlignment(HorizontalAlignment.CENTER);
        return headStyle;
    }

    private static WriteCellStyle contentStyle() {
        WriteCellStyle contentStyle = new WriteCellStyle();
        WriteFont contentFont = new WriteFont();
        contentFont.setFontHeightInPoints((short) 12);
        contentStyle.setWriteFont(contentFont);
        contentStyle.setWrapped(false);
        contentStyle.setVerticalAlignment(VerticalAlignment.CENTER);
        return contentStyle;
    }


}
